|
|
|
|
|
|
|
Solution 30
File Operations, Part 1 |
|
|
|
|
|
|
|
|
The obvious place to start looking is with the SHFILEOPSTRUCT structure and its VB declaration. After all, what else could the problem be? |
|
|
|
|
|
|
|
|
As you recall, the C declaration for the structure is as follows: |
|
|
|
|
|
|
|
|
typedef struct _SHFILEOPSTRUCT { // shfos
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, FAR *LPSHFILEOPSTRUCT; |
|
|
|
|
|
|
|
|
And the VB declaration for the structure is as follows: |
|
|
|
|
|
|
|
|
Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String ' only used if FOF_SIMPLEPROGRESS
End Type |
|
|
|
|
|
|
|
|
Your first thought might be to suspect the strings. If you've read Tutorial 7, "Classes, Structures, and User-Defined Types" (found in Part III of this book), you know that it can be dangerous to use dynamic strings inside structuresespecially if the API function modifies the contents of those fields in any way. That's because a dynamic string inside a structure holds a 32-bit BSTR value. The Win32 API does not know how to use BSTRs, so any attempt it makes to modify |
|
|
|
|
|